package boddaert.philippe.cashGame;

import java.util.ArrayList;
import java.util.List;

public class Game {

	private String title;

	private List<GameConfiguration> configurations = new ArrayList<GameConfiguration>();

	public Game() {
	}

	public void setTitle(String title) {
		this.title = title;

	}

	public String getTitle() {
		return this.title;
	}

	public int getConfigurationNumber() {
		return this.configurations.size();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		if (!(obj instanceof Game))
			return false;

		Game objGame = (Game) obj;

		return this.title.toUpperCase()
				.equals(objGame.getTitle().toUpperCase());
	}

	public GameConfiguration getConfiguration() {
		return this.configurations.get(0);
	}

	public void addConfiguration(GameConfiguration configuration) {
		this.configurations.add(configuration);
	}

	public List<GameConfiguration> getConfigurations() {
		return this.configurations;
	}

	public GameConfiguration getConfiguration(int i) {
		return this.configurations.get(i);
	}

	public GameConfiguration getConfiguration(String name) {
		for (GameConfiguration configuration : this.configurations) {
			if (name.equals(configuration.getSite()))
				return configuration;
		}
		return null;
	}

}
